package com.a214.yxz.yuejian013.Fragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.a214.yxz.yuejian013.Base.BaseSFragment;
import com.a214.yxz.yuejian013.JavaBean.ClubcourseBean;
import com.a214.yxz.yuejian013.Adapter.ClubCourseAdapter;
import com.a214.yxz.yuejian013.Listener.ServiceListener;
import com.a214.yxz.yuejian013.Model.ResModel;
import com.a214.yxz.yuejian013.R;

import java.util.List;

/**
 * A simple {@link BaseSFragment} subclass.
 */
public class ClubCourseFragment extends BaseSFragment {
    private RecyclerView.LayoutManager layoutManager;
    private RecyclerView recyclerView;
    private ClubCourseAdapter adapter;
    private ServiceListener<List<ClubcourseBean>> listener;
    private ResModel model = new ResModel("gson",getSessionID());


    public ClubCourseFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_club_course, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        recyclerView= (RecyclerView) view.findViewById(R.id.club_course_list);
        adapter=new ClubCourseAdapter(getContext());
        layoutManager=new LinearLayoutManager(getContext());

        recyclerView.setAdapter(adapter);
        recyclerView.setLayoutManager(layoutManager);

        listener=new ServiceListener<List<ClubcourseBean>>() {
            @Override
            public void onResponse(List<ClubcourseBean> l) {
                adapter.setList(l);
            }

            @Override
            public void onFail(String msg) {
                Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT).show();
            }
        };
        //model.getClubDetail("course",getActivity().getIntent().getStringExtra("club_id"),listener);
        model.getClubDetail("course","1",listener);
    }
}

